package tianrun.ziguan.api.calculate.config.controller.statics;

import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tianrun.ziguan.api.calculate.config.dto.request.UpdateStaticPropertiesParam;
import tianrun.ziguan.api.calculate.config.service.asset.module.ITAssetStaticPropertiesModuleService;
import tianrun.ziguan.api.calculate.config.utils.HttpResponseTools;
import tianrun.ziguan.api.common.core.base.ReturnMessage;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("static/properties")
@Api(tags = "静态组件")
public class StaticPropertiesController {


    private final ITAssetStaticPropertiesModuleService assetStaticPropertiesModuleService;

    public StaticPropertiesController(ITAssetStaticPropertiesModuleService assetStaticPropertiesModuleService) {
        this.assetStaticPropertiesModuleService = assetStaticPropertiesModuleService;
    }


    @ApiOperation(value = "根据资产和点位修改静态实例的值")
    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @PostMapping("updateValueByLabel")
    public ResponseEntity<ReturnMessage> updateValueByLabel(@RequestBody @Valid List<UpdateStaticPropertiesParam> params){
        assetStaticPropertiesModuleService.updateValueByLabel(params);
        return HttpResponseTools.good();
    }

}
